﻿@model Entities.Risk
@{
    ViewBag.Title = "Подробности";
}
<h2>
    Информация об угрозе "@Model.RiskFactor.Title" проекта "@Model.Project.Title"</h2>
@if (User.IsInRole("ProjectManager"))
{
    <fieldset>
        <legend>Численные параметры</legend>
        @using (Html.BeginForm())
        {
            <div class="display-label" style="display: none">
                ProjectRiskId</div>
            <div class="display-field" style="display: none">
                @Html.EditorFor(model => model.ProjectRiskId)
            </div>
        
            <div class="display-label" style="display: none">
                ProjectId</div>
            <div class="display-field" style="display: none">
                @Html.EditorFor(model => model.ProjectId)
            </div>
            <div class="display-label" style="display: none">
                RiskId</div>
            <div class="display-field" style="display: none">
                @Html.EditorFor(model => model.RiskId)
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.Probability)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Probability)
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.Cost)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Cost)
            </div>
            <br />
            <input type="submit" value="Пересчитать" />
        }
    </fieldset>
}
<h4>
    Список мероприятий
    @if (User.IsInRole("ProjectManager"))
    {
        @String.Format("[")
        @Html.ActionLink("Добавить", "Create", "Measure", new { id = Model.ProjectRiskId }, null)
        @String.Format("]")
    }
</h4>
<table>
    <tr>
        <td>
            <b>Название</b>
        </td>
        <td>
            <b>Начать до</b>
        </td>
        <td>
            <b>Завершить до</b>
        </td>
        <td>
            <b>Начато</b>
        </td>
        <td>
            <b>Завершено</b>
        </td>
        <td>
            <b>Ответственный</b>
        </td>
        @if (User.IsInRole("ProjectManager"))
        {
            <td>
                <b>Действия</b>
            </td>
        }
    </tr>
    @foreach (Entities.Measure measure in Model.Measures)
    {
        <tr>
            <td>
                @Html.ActionLink(@measure.Title, "ViewDetails", "Measure", new { id = measure.MeasureId }, null)
            </td>
            <td>@RMSoftware.Tools.FormatDate(measure.ReqBegDate)
            </td>
            <td>@RMSoftware.Tools.FormatDate(measure.ReqEndDate)
            </td>
            <td>@RMSoftware.Tools.FormatDate(measure.BegDate)
            </td>
            <td>@RMSoftware.Tools.FormatDate(measure.EndDate)
            </td>
            <td>@String.Format("{0} {1}", measure.Person.LastName, measure.Person.FirstName, measure.Person.Position)
            </td>
            @if (User.IsInRole("ProjectManager"))
            {
                <td>
                    @Html.ActionLink("Удалить", "Delete", "Measure", new { id = measure.MeasureId }, null)
                </td>
            }
        </tr>
    }
</table>
<p>
    @Html.ActionLink("К текущему проекту", "ViewDetails", "Project", new { id = Model.ProjectId }, null)
</p>
